import axios from "axios";
import {message} from 'antd';
// 添加请求拦截器
axios.interceptors.request.use((config) => {
    // 在发送请求之前做些什么
    const token = localStorage.getItem('access_token') || localStorage.getItem('accessToken') || 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6MCwiand0VHlwZSI6InVzZXIiLCJ1c2VySWQiOiIxIiwidGVuYW50SWQiOiIxIiwidXNlcm5hbWUiOiJBRE1JTiIsInNlc3Npb25Ub2tlbiI6ImMxYTg0OGU4NjJhMzRkN2U4ZjQyNGFlY2JmM2ZjMmQ1IiwiaXNzIjoiZHJpZ2h0Iiwic3ViIjoiYWNjZXNzVG9rZW4iLCJpYXQiOjE2NzM1NzY5NTcsIm5iZiI6MTY3MzU3Njg5N30.cRp4REjr4VFlZfMv9CiILl04mttsDRvXlwneeDMgWq0';
    config.headers = {
        ...config.headers,
        "Authorization": token,
    };
    return config;
  }, (error) => {
    // 对请求错误做些什么
    return Promise.reject(error);
  });

// 添加响应拦截器
axios.interceptors.response.use((response) => {
    // 对响应数据做点什么
    return response;
  }, (error) => {
    // 对响应错误做点什么
    message.error(error)
    return Promise.reject(error);
  });


  export default axios;